﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace YJKRevitBase.WinForm.WinFormRemindSuit
{
	internal class PointReflectPropertySeter : GeneralReflectPropertySeter<Point>, IAttributeSeter
	{
		private PointReflectPropertySeter()
		{
		}

		internal static PointReflectPropertySeter GetPointReflectPropertySeter()
		{
			if (PointReflectPropertySeter.m_singleTag == null)
			{
				PointReflectPropertySeter.m_singleTag = new PointReflectPropertySeter();
			}
			return PointReflectPropertySeter.m_singleTag;
		}

		public bool TrySetOneAttribute(ref System.Windows.Forms.Control inputControl, AttributeInformationBean inputAttribute)
		{
			return base.TrySetOneAttributeGeneral(ref inputControl, inputAttribute, new AppendTransform<Point>(this.AppendTransformPoint));
		}

		protected override Point GetValueOfString(string inputStr)
		{
			List<int> list = new List<int>();
			string pattern = "(?<=X=)\\d*";
			foreach (object obj in Regex.Matches(inputStr, pattern))
			{
				int item = int.Parse(((Match)obj).Value);
				list.Add(item);
			}
			string pattern2 = "(?<=Y=)\\d*";
			foreach (object obj2 in Regex.Matches(inputStr, pattern2))
			{
				int item2 = int.Parse(((Match)obj2).Value);
				list.Add(item2);
			}
			return new Point(list[0], list[1]);
		}

		private Point AppendTransformPoint(System.Windows.Forms.Control inputControl, AttributeInformationBean inputAttribute, Point inputPoint)
		{
			if (!(inputControl is System.Windows.Forms.Form))
			{
				return inputPoint;
			}
			return WinFormUtilityMethod.SetValidFormLocation(inputControl as Form, inputPoint);
		}

		private static PointReflectPropertySeter m_singleTag;
	}
}
